import type { FieldRule } from 'vant'

export const mobileRules: FieldRule[] = [
  {
    required: true,
    message: '请输入手机号'
  },
  {
    pattern:
      /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/,
    message: '手机号格式错误'
  }
]

export const passwordRules: FieldRule[] = [
  {
    required: true,
    message: '请输入密码'
  },
  {
    pattern: /^\w{8,24}$/,
    message: '密码格式错误'
  }
]
export const codeRules: FieldRule[] = [
  {
    required: true,
    message: '请输入验证码'
  },
  {
    pattern: /^\d{6}$/,
    message: '验证码格式错误'
  }
]

export const idCardRules: FieldRule[] = [
  {
    required: true,
    message: '请输入患者身份证号码'
  },

  {
    pattern:
      /^(\d{6})(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)(\d{3}[\dXx])$/,
    // pattern: /^(\d{14})(\d{3}[\dx])$/,
    message: '患者身份证号码格式错误'
  }
]

export const nameRules: FieldRule[] = [
  {
    required: true,
    message: '请输入患者姓名'
  },
  {
    pattern: /^[\u4e00-\u9fa5]{2,4}$/,
    message: '患者姓名格式错误'
  }
]

export const contentReg = /<[^>]+(?:>|\/>)/g
